#include<stdio.h>
#include<stdlib.h>

int reverse( int m ){
	int result = 0;
	while( m != 0 ){
		result = result * 10 + m % 10;
		m = m / 10;
	}
	return result;
}

int rotate( int m ){
	if( m < 0 )
		return -rotate( -m );
	else if( m < 10 )
		return m;
	else{
		int n = 1;
		while( m > n )
			n *= 10;
		n /= 10;
		return ( m%10 ) * n + ( m % n / 10 ) * 10 + m / n;
	}
}

int main( ){
	int a = 123456;
	printf( "%d", rotate( a ) );
}
